package com.xbongbong.pro.targetlog.pojo;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author zcp
 * @version v1.0
 * @date 2019/4/15 19:01
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class ReportTargetPojo implements Serializable {
    private static final long serialVersionUID = -2246567118519366158L;

    /**
     * 新增客户数：本月，今日
     */
    private Integer countCustomerM = 0;
    private Integer countCustomerD = 0;
    /**
     * 新增合同客户数：本月，今日
     */
    private Integer countCustomerConM = 0;
    private Integer countCustomerConD = 0;
    /**
     * 新增机会客户数：本月，今日
     */
    private Integer countCustomerOppM = 0;
    private Integer countCustomerOppD = 0;
    /**
     * 跟进客户数：本月，今日
     */
    private Integer countFollowCustomerM = 0;
    private Integer countFollowCustomerD = 0;
    /**
     * 跟进次数：本月，今日
     */
    private Integer countCommunicateM = 0;
    private Integer countCommunicateD = 0;
    /**
     *
     */
    //签约合同数：本月，今日
    private Integer countContractM = 0;
    private Integer countContractD = 0;
    /**
     * 签约合同金额：本月，今日
     */
    private Double amountContractM = 0d;
    private Double amountContractD = 0d;
    /**
     * 新增机会数：本月，今日
     */
    private Integer countOpportunityAddM = 0;
    private Integer countOpportunityAddD = 0;
    /**
     * 新增机会金额：本月，今日
     */
    private Double amountOpportunityAddM = 0d;
    private Double amountOpportunityAddD = 0d;
    /**
     * 赢单机会数：本月，今日
     */
    private Integer countOpportunityWinM = 0;
    private Integer countOpportunityWinD = 0;
    /**
     * 赢单机会金额：本月，今日
     */
    private Double amountOpportunityWinM = 0d;
    private Double amountOpportunityWinD = 0d;
    /**
     * 跟进机会数：本月，今日
     */
    private Integer countFollowOpportunityM = 0;
    private Integer countFollowOpportunityD = 0;
    /**
     * 已回款金额：本月，今日
     */
    private Double amountPaymentEdM = 0d;
    private Double amountPaymentEdD = 0d;
    /**
     * 未收款金额：本月，今日
     */
    private Double amountPaymentUnM = 0d;
    private Double amountPaymentUnD = 0d;
    /**
     * 已付款金额：本月，今日
     */
    private Double amountPayEdM = 0d;
    private Double amountPayEdD = 0d;
    /**
     * 未付款金额：本月，今日
     */
    private Double amountPayUnM = 0d;
    private Double amountPayUnD = 0d;
    /**
     * 已开票金额：本月，今日
     */
    private Double amountInvoiceM = 0d;
    private Double amountInvoiceD = 0d;
    /**
     * 采购单数量：本月，今日
     */
    private Integer countPurchaseM = 0;
    private Integer countPurchaseD = 0;
    /**
     * 采购金额：本月，今日
     */
    private Double amountPurchaseM = 0d;
    private Double amountPurchaseD = 0d;
    /**
     * 入库产品数：本月，今日
     */
    private Double countInstockM = 0d;
    private Double countInstockD = 0d;
    /**
     * 出库产品数：本月，今日
     */
    private Double countOutstockM = 0d;
    private Double countOutstockD = 0d;

    /**
     * 判断几个推送的指标当日是否有数据（无数据的话，无需推送）
     *
     * 需要判断的指标有：
     * 		客户：新增客户数、跟进客户数、跟进记录数
     * 		合同回款：签约合同金额、已回款、应收未收款
     * 		机会：新增机会金额、赢单机会金额
     *
     * @return
     * @since 3.11
     * @version
     * @author cp.zhang
     * @date 2017-8-9 下午3:49:56
     * @update 2019-4-15 从saas移入 by zcp
     */
    public boolean checkTarget() {
        boolean flag = checkValue(this.countCustomerD)
                || checkValue(this.countFollowCustomerD)
                || checkValue(this.countCommunicateD)
                || checkValue(this.amountContractD)
                || checkValue(this.amountPaymentEdD)
                || checkValue(this.amountPaymentUnD)
                || checkValue(this.amountOpportunityAddD)
                || checkValue(this.amountOpportunityWinD);
        return flag;
    }

    /**
     * 判断是否有指标存在，返回false则该员工指标不存库
     *
     * @return
     * @since 3.11
     * @version
     * @author cp.zhang
     * @date 2017-8-10 下午2:31:59
     * @update 2019-4-15 从saas移入 by zcp
     */
    public boolean isEmpty() {
        boolean flag = checkValue(this.countCustomerD)
                || checkValue(this.countCustomerConD)
                || checkValue(this.countCustomerOppD)
                || checkValue(this.countFollowCustomerD)
                || checkValue(this.countCommunicateD)
                || checkValue(this.countContractD)
                || checkValue(this.amountContractD)
                || checkValue(this.countOpportunityAddD)
                || checkValue(this.amountOpportunityAddD)
                || checkValue(this.countOpportunityWinD)
                || checkValue(this.amountOpportunityWinD)
                || checkValue(this.countFollowOpportunityD)
                || checkValue(this.amountPaymentEdD)
                || checkValue(this.amountPaymentUnD)
                || checkValue(this.amountPayEdD)
                || checkValue(this.amountPayUnD)
                || checkValue(this.amountInvoiceD)
                || checkValue(this.countPurchaseD)
                || checkValue(this.amountPurchaseD)
                || checkValue(this.countInstockD)
                || checkValue(this.countOutstockD);
        return flag;
    }
    /**
     * 判断值是否大于0
     * @param value
     * @return boolean 
     * @author zcp
     * @date 2019/4/15 19:30
     * @since v1.0
     * @version v1.0
     */
    private boolean checkValue(Object value){
        if (value instanceof Integer) {
            Integer valueInt = (Integer) value;
            if (valueInt != null && valueInt > 0) {
                return true;
            }
        } else {
            Double valueDouble = (Double) value;
            if (valueDouble != null && valueDouble > 0) {
                return true;
            }
        }
        return false;
    }
}
